package com.util;

import java.util.*;

/**
 *
 * @方法描述：获取两个ArrayList的交集
 *
 *
 * @return resultList 交集ArrayList
 */
public class ReceiveCollectionList {

    public List receiveCollectionList(List firstArrayList, List secondArrayList) {

        List resultList = new ArrayList();
        LinkedList result = new LinkedList(firstArrayList);// 大集合用linkedlist
        HashSet othHash = new HashSet(secondArrayList);// 小集合用hashset
        Iterator iter = result.iterator();// 采用Iterator迭代器进行数据的操作
        while (iter.hasNext()) {
            if (!othHash.contains(iter.next())) {
                iter.remove();
            }
        }

        resultList = new ArrayList(result);
        return resultList;
    }


}
